﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 编程能力._1491.去掉最低工资和最高工资后的平均工资
{
    class MainProject
    {
        public static double Average(int[] salary)
        {
            //排序，求平均值
            int minS = Int32.MaxValue;
            int maxS = Int32.MinValue;
            int sum = 0;
            for (int i = 0; i < salary.Length; ++i)
            {
                sum += salary[i];
                minS = Math.Min(minS, salary[i]);
                maxS = Math.Max(maxS, salary[i]);
            }
            return 1.0 * (sum - minS - maxS) / (salary.Length - 2);
        }
    }
}
